function [y, x] = sum_boltzman(varargin);
% sum_boltzman:
% calculate sum of multiple boltzman functions at specified X locations.
%
y=[];
x=[];
if(nargin == 0)
   fprintf('sum_boltzman: \n');
   fprintf('call: sum_boltzman(x, [offset, amplitude, slope, vhalf, a2, s2, vh2, ...])\n');
   fprintf(' or with more amplitude, slope, vhalf values for sum of multiple functions\n');
   return;
end;
if(nargin == 2) % passed as x and array

x=varargin{1};
offset = varargin{2}(1);
j = 0;
for i = 3:3:length(varargin)
   j = j + 1;
   a(j) = varargin{2}(i);
   s(j) = varargin{2}(i+1);
   vh(j) = varargin{2}(i+2);
end;

% do computation

y=zeros(length(x), 1);
for i = 1:j % for all boltzman paramters.
   y = y + (a(j)-o)/(1+exp(-(x-vh(i))*s(j)));
end;
y = y + offset;
return;
